package com.photovoltaic.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.photovoltaic.auth.entity.Permission;
import com.photovoltaic.auth.mapper.PermissionMapper;
import com.photovoltaic.auth.service.PermissionService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements PermissionService {
    
    @Override
    public Permission findByCode(String code) {
        LambdaQueryWrapper<Permission> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Permission::getPermissionKey, code);
        return getOne(queryWrapper);
    }
    
    @Override
    public List<Permission> findByType(Integer type) {
        LambdaQueryWrapper<Permission> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Permission::getId, type);
        return list(queryWrapper);
    }
} 